import { defineStore } from 'pinia'

export const useFeishuStore = defineStore('feishu', {
  state: () => ({
    appId: '',
    appSecret: '',
    accessToken: '',
    expireAt: null
  }),

  actions: {
    // 登录成功
    authorizeSuccess(data: any) {
      void data
    },
    /**
     * 初始化
     */
    initialize() {
      return new Promise((resolve, reject): void => {
        (async () => {
          const appService = await import('@/api/service/AppService')
          appService.initFeishu().then(resolve).catch(reject)
        })()
      })
    }
  }
})
